import request from '@/router/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/api/xmbz-system/dept/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}
export const remove = (ids) => {
  return request({
    url: '/api/xmbz-system/dept/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const add = (row) => {
  return request({
    url: '/api/xmbz-system/dept/submit',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: '/api/xmbz-system/dept/submit',
    method: 'post',
    data: row
  })
}

export const getDept = (id) => {
  return request({
    url: '/api/xmbz-system/dept/detail',
    method: 'get',
    params: {
      id,
    }
  })
}
export const getDeptTree = (tenantId) => {
  return request({
    url: '/api/xmbz-system/dept/tree',
    method: 'get',
    params: {
      tenantId,
    }
  })
}

// 获取只显示城市的部门树形结构
export const getDeptCityTree = (tenantId) => {
  return request({
    url: '/api/xmbz-system/dept/getDeptCityTree',
    // url: 'http://192.168.2.106:8108/dept/getDeptCityTree',
    method: 'get',
    params: {
      tenantId
    }
  })
}

// 城市权限
export const getCityJurisdiction = (query) => {
  return request({
    url: '/api/xmbz-system/role/getCityJurisdiction',
    // url: 'http://192.168.2.106:8108/role/getCityJurisdiction',
    method: 'get',
    params: query
  })
}

export const updateRoleDept = (row) => {
  return request({
    url: '/api/xmbz-system/role/updateRoleDept',
    method: 'post',
    data: row
  })
}

// 获取仓库权限数据 xmbz-order
export const getWareHouseGroupByDeptId = (roleId) => {
  return request({
    url: '/api/xmbz-order/warehouse/getWareHouseGroupByDeptId',
    // url: 'http://192.168.2.106:8108/dept/getWareHouseGroupByDeptId',
    method: 'get',
    params: {
      roleId
    }
  })
}

// 保存/更新仓库权限 xmbz-system
export const saveOrUpdateRoleWarehouse = (row) => {
  return request({
    url: '/api/xmbz-system/role/saveOrUpdateRoleWarehouse',
    method: 'post',
    data: row
  })
}

